Printer Click
Printer Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Oct 2024.
- Type : UART type
Software Support
Example Description
This example demonstrates the use of Printer Click board by providing user interaction with a thermal printer, allowing the user to check paper status, display commands, and execute various printing tasks based on user commands through a UART interface.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Printer
Example Key Functions
- printer_cfg_setup Config Object Initialization function.
void printer_cfg_setup(printer_cfg_t *cfg)
Printer configuration object setup function.
Printer Click configuration object.
Definition printer.h:262
- printer_init Initialization function.
err_t printer_init(printer_t *ctx, printer_cfg_t *cfg)
Printer initialization function.
Printer Click context object.
Definition printer.h:241
- printer_default_cfg Click Default Configuration function.
err_t printer_default_cfg(printer_t *ctx)
Printer default configuration function.
- printer_get_status This function reads the paper status and temperature of the printer and stores results in ctx->status string buffer.
err_t printer_get_status(printer_t *ctx)
Printer get status function.
- printer_get_fw_info This function reads the firmware information of the printer and stores results in ctx->fw_info string buffer.
err_t printer_get_fw_info(printer_t *ctx)
Printer get FW info function.
- printer_print_string_lf This function prints a string message with line feed.
err_t printer_print_string_lf(printer_t *ctx, char *data_in)
Printer print string function.
Application Init
Initializes the driver, performs the Click default configuration, and displays the list of supported commands on the USB UART.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
printer_display_commands ( );
log_info( &logger, " Application Task " );
}
#define PRINTER_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition printer.h:228
void application_init(void)
Definition main.c:66
#define MIKROBUS_POSITION_PRINTER
Definition main.c:31
@ PRINTER_ERROR
Definition printer.h:286
Application Task
Checks the paper status and processes user commands.
{
uint8_t command = 0;
printer_check_paper ( &printer );
if ( 1 == log_read ( &logger, &command, 1 ) )
{
printer_parse_command ( &printer, command );
}
}
void application_task(void)
Definition main.c:103
Note
The default printer head type is set to LTP02-245-13.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.